#include <iostream>

using namespace std;

int main(){
	int bp = 0,an = 0;
	cin >> bp;
	for(int i = 0; i < 5; i++){
		int n;
		cin >> n;
		if (n >= bp){
			if (n-bp>=an){
				an = n-bp;
			}
		}
	}
	cout << an+1 ;
} 
